<template>
    <div class="login">
        <img src="../assets/图标/登录页-2.jpg" alt="">
       <van-form @submit="onSubmit">
  <van-field
    v-model="username"
    name="用户名"
    label="用户名"
    placeholder="用户名"
    :rules="[{ required: true, message: '请填写用户名' }]"
  />
  <van-field
    v-model="password"
    type="password"
    name="密码"
    label="密码"
    placeholder="密码"
    :rules="[{ required: true, message: '请填写密码' }]"
  />
  <div style="margin: 16px;">
    <van-button round block type="info" native-type="submit">注册</van-button>
  </div>
</van-form>
    </div>
</template>

<script>
import {GetRegister} from '../raxios/api'
import { Toast } from 'vant';
export default {
    data () {
        return {
      username: '',
      password: '',
 
        }
    },
    methods:{
        link(){
            this.$router.push('/register-index')
        }, 
         onSubmit(values) {
    //   console.log('submit', values);
      let phone =values['用户名']
      let password =values['密码']
      GetRegister({phone,password}).then(res=>{
          // console.log(res);
          if(res.errCode==0){
             Toast.success('注册成功');
             setTimeout(()=>{
            this.$router.push('/register-index')
             },800)
          }else{
             Toast.fail('该账号已被注册');
          }
      })
    },
    },
    components:{
    }
}
</script>
 
<style lang = "less" scoped>
    .login{
        img{
            width: 100%;
            background: no-repeat;
        }
    }
    /deep/.van-form{
        position: fixed;
        bottom: 4%;
        /* background-color: yellowgreen; */
        left: 10%;
    }
    /deep/.van-cell {
      border-radius: 0.1rem;
      margin-top: 0.1rem;
      border: 1px solid #FEFEFE;
    }
</style>